import { post, put, get } from '@/utils/http/Axios';

// 查询待办
export const getTodoList: FetchProcessList = data => {
  return post('/workflow-platform/api/v1/process_instance/task/todo_list', data).then(resp => resp.data);
};

// 查询我申请的
export const getMyCreateList: FetchProcessList = data => {
  return post('/workflow-platform/api/v1/process_instance/task/my_create_list', data).then(resp => resp.data);
};
// 查询已办
export const getDoneList: FetchProcessList = data => {
  return post('/workflow-platform/api/v1/process_instance/task/done_list', data).then(resp => resp.data);
};
//  获取抄送我的列表
export const getCcList: FetchProcessList = data => {
  return post('/workflow-platform/api/v1/process_instance/task/cc_list', data).then(resp => resp.data);
};
//  审批流程
// TODO:明确参数类型
export function setProcessApproval(data: any) {
  return put('/workflow-platform/api/v1/process_instance/task/approve', data);
}
// 我发起的--流程撤销
// TODO:明确参数类型
export function processCancel(data: any) {
  const { processInstanceId, revokeReason } = data;
  return put(`/workflow-platform/api/v1/process_instance/revoke/${processInstanceId}`, { revokeReason });
}

// 审批待办的退回接口
// TODO:明确参数类型
export function processInstanceRollback(data: any) {
  return put('/taishan-runtime/api/v5/process/process_instance/rollback', data);
}
// 流程催办
export function setProcessUrge(processInstanceId: string) {
  return put(`/workflow-platform/api/v1/process_instance/urge/${processInstanceId}`);
}

/*
 *  应用端查看流程详情
 */
export function fetchProcessDetail(processInstanceId: string, taskId: string): Promise<Result<ProcessDetail>> {
  return get(`/workflow-platform/api/v1/process_instance/detail/${processInstanceId}/${taskId}`);
}
